package test_unitaire;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import buisness_service.Finance_annee;
import buisness_service.Finance_jour;
import buisness_service.Finance_mois;
import buisness_service.Rapport;
import buisness_service.Rapport.Mois;
import buisness_service.User;

public class Test_Finance_jour {

	@Test
	public void testFinance_jour() {

		User u= new User();
		Finance_annee f_a = new Finance_annee(2008,u.getRapport());
		Finance_mois f = new Finance_mois(Mois.Mai, f_a, u);
		Finance_jour f_j = new Finance_jour(19, f,u );
		assertTrue(f_j.getJour() == 19);
		assertTrue(f_j.getFinance_mois() == f);
		assertTrue(u.getRapport().get(f.getIndexFinance_annee())
				.getFinances_mois().get(f.getIndex_finance_mois())
				.getFinances_jour().get(0) == f_j);
		assertTrue(f_j.getIndex_finance_jour() == 0);

		Finance_jour f_j2 = new Finance_jour(20, f, u );
		assertTrue(f_j2.getJour() == 20);
		assertTrue(u.getRapport().get(f.getIndexFinance_annee())
				.getFinances_mois().get(f.getIndex_finance_mois())
				.getFinances_jour().get(1) == f_j2);

		assertTrue(f_j2.getIndex_finance_jour() == 1);

		Finance_mois f2 = new Finance_mois(Mois.Mars, f_a, u);
		Finance_jour f_j3 = new Finance_jour(19, f2, u);
		assertTrue(f_j3.getJour() == 19);
		assertTrue(u.getRapport().get(f2.getIndexFinance_annee())
				.getFinances_mois().get(f2.getIndex_finance_mois())
				.getFinances_jour().get(0) == f_j3);
		assertTrue(f_j3.getIndex_finance_jour() == 0);
		
		Rapport.postesDpenses.clear();
		Rapport.postesRevenus.clear();
	}

}
